/**
 * Copyright (C) 2009 Ignasi Fosch Alonso
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation; either version 2 of the License, or (at your option) any later
 * version.
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 
 * details.
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
 * Place, Suite 330, Boston, MA 02111-1307 USA
 *
 * You can reach me by mail at natx@y10k.ws
 * You can reach him by paper mail at:
 * C. LLEIDA, 41-43, 3r 1a
 * El Prat de Llobregat 08820
 * Barcelona, SPAIN
 */
package ws.y10k.vsmanager;

import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;

import ws.y10k.swt.utils.ShellUtils;

/**
 * @author natx
 *
 */
public class AddHostWindow extends Window {
	
	Text txtHostname;
	Text txtUser;
	Text txtPassword;
	Button btnProtocolHTTP;
	Button btnProtocolHTTPS;
		
	AddHostWindow(Window parent) {
		super(parent);
		this.open();
	}
	
	public Control createContents(Composite parent) {
		// TODO i18n
		parent.getShell().setSize(400, 230);
		ShellUtils.center(parent.getShell());
		parent.getShell().setText("Add Host");
		RowLayout row = new RowLayout();
		row.pack = false;
		parent.getShell().setLayout(row);
		
		Composite cmpAddHost = new Composite(parent, SWT.NONE);
		cmpAddHost.setSize(50, 50);
		cmpAddHost.setLocation(0, 0);
		GridLayout grd = new GridLayout();
		grd.numColumns = 2;
		cmpAddHost.setLayout(grd);
		
		Label lblHostname = new Label(cmpAddHost, SWT.NONE);
		lblHostname.setText("&Hostname");
		GridData grdData = new GridData();
		grdData.widthHint = 85;
		lblHostname.setLayoutData(grdData);
		
		txtHostname = new Text(cmpAddHost, SWT.BORDER);
		grdData = new GridData();
		grdData.widthHint = 285;
		txtHostname.setLayoutData(grdData);
		
		Label lblUser = new Label(cmpAddHost, SWT.NONE);
		lblUser.setText("&User");
		grdData = new GridData();
		grdData.widthHint = 85;
		lblUser.setLayoutData(grdData);
		
		txtUser = new Text(cmpAddHost, SWT.BORDER);
		grdData = new GridData();
		grdData.widthHint = 285;
		txtUser.setLayoutData(grdData);
		
		Label lblPassword = new Label(cmpAddHost, SWT.NONE);
		lblPassword.setText("&Password");
		grdData = new GridData();
		grdData.widthHint = 85;
		lblPassword.setLayoutData(grdData);
		
		txtPassword = new Text(cmpAddHost, SWT.BORDER);
		txtPassword.setEchoChar('*');
		grdData = new GridData();
		grdData.widthHint = 285;
		txtPassword.setLayoutData(grdData);
		
		Group grpProtocol = new Group(cmpAddHost, SWT.SHADOW_ETCHED_IN);
		grpProtocol.setSize(110,75);
		grpProtocol.setText("Protocol");
		grpProtocol.setLayout(new RowLayout());
		grdData = new GridData();
		grdData.widthHint = 120;
		grdData.horizontalSpan = 2;
		grdData.horizontalAlignment = SWT.CENTER;
		grpProtocol.setLayoutData(grdData);

		btnProtocolHTTPS = new Button(grpProtocol, SWT.RADIO);
		btnProtocolHTTPS.setText("HTTPS");
		btnProtocolHTTPS.setSelection(true);
		
		btnProtocolHTTP = new Button(grpProtocol, SWT.RADIO);
		btnProtocolHTTP.setText("HTTP");
		
		Button btnConnect = new Button(cmpAddHost, SWT.PUSH);
		btnConnect.setText("&Connect");
		grdData = new GridData();
		grdData.widthHint = 120;
		grdData.horizontalSpan = 2;
		grdData.horizontalAlignment = SWT.CENTER;
		btnConnect.setLayoutData(grdData);
		btnConnect.addSelectionListener(new ConnectButtonSelectionListener(this));
		parent.getShell().setDefaultButton(btnConnect);
		
		return parent;
	}

}
